package com.jk.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

;

/**
 * @author yzf
 * @version 1.0
 * @ClassName TopicRabbitConfig
 * @program: yzf-test
 * @description: TODO
 * @date 2025/2/27 16:23
 */
@Configuration
public class TopicRabbitConfig {
    // yzf TODO 2025/3/10 rabbitMQ:


    final static String message = "topic.message";

    final static String messages = "topic.messages";

    @Bean
    // 创建队列
    public Queue QueueMessage(){
        return new Queue(TopicRabbitConfig.message);
    }
    @Bean
    public Queue QueueMessages(){
        return new Queue(TopicRabbitConfig.messages);
    }

    @Bean
    // 创建交换机
    public TopicExchange exchange(){
        return new TopicExchange("exchange");
    }
    @Bean
    // 绑定队列到交换机
    public Binding bindingExchangeMessage(Queue QueueMessage, TopicExchange exchange){
        return BindingBuilder.bind(QueueMessage).to(exchange).with("topic.message");
    }
    @Bean
    public Binding bindingExchangeMessages(Queue QueueMessages,TopicExchange exchange){
    return BindingBuilder.bind(QueueMessages).to(exchange).with("topic.#");
    }


}
